package com.itheima.many_to_many;

import com.itheima.bean.Student;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper {
    // 查询所有
    @Select("SELECT DISTINCT s.`id`,s.`NAME`,s.`age` FROM student s,stu_cr sc WHERE s.`id`=sc.`sid`")
    @Results({
            @Result(column = "id",property = "id"),
            @Result(column = "naem",property = "naem"),
            @Result(column = "age",property = "age"),
            @Result(
                    property = "course",
                    javaType = List.class,
                    column = "id",

                    many = @Many(select = "com.itheima.many_to_many.CourseMapper.selectById")
            )
    })
    public abstract List<Student> selectAll();
}
